<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        div {
            width: 600px;
            height: 600px;
            margin: 100px auto;
            border: 1px solid #333;
        }
        
        #image {
            width: 600px;
            height: 600px;
        }
    </style>
</head>

<body>
    <div class="a">
        <img id="image" src="../m2114/img/1.jpg" alt="" />
    </div>
    <button>随机</button>
    <script>
        var images = document.getElementById("image");
        var btn = document.querySelector("button");
        var img_arr = [
            "../m2114/img/1.jpg",
            "../m2114/img/2.jpg",
            "../m2114/img/3.jpg",
        ];
        btn.onclick = function() {
            var random = Math.floor(Math.random() * img_arr.length);
            images.src = img_arr[random];
        };
    </script>
</body>

</html>